#include "people.h"

people::people(QObject *parent) : QObject(parent)
{
    //导入图片
    p_people.load(PEOPLE_PATH);
    //初始化坐标
    pX=0;
    pY=posY;
    //初始化边框
    rect.setWidth(90);
    rect.setHeight(160);
    rect.setLeft(pX);
    rect.setTop(pY);
}

void people::updatePosition()
{
    if(presskey!=2)
        rect.setHeight(160);
    if(presskey!=4)
    {
        if(pY<posY)
            pY+=30;
        else
            pY=posY;
    }
    if(presskey==4)
    {
        if(pY>=215)
            pY-=30;
        else
            pY=200;
    }


    if(presskey==1)
    {
        if(pX>=8)
        {
            pX-=16;
        }
        else
        {
            pX=0;
        }
    }
    if(presskey==3)
    {
        if(pX<=1300)
        {
            pX+=14;
        }
        else
        {
            pX=1314;
        }
    }

    if(presskey==2)
    {
        pY+=80;
        rect.setHeight(80);
    }

    rect.moveTo(pX,pY);

}






